package com.toman.ui.work.workshop;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.toman.Enum.BaseEnum;
import com.toman.JavaBean.ArleadyReceiveSendworkOrderCount;
import com.toman.JavaBean.ReceiveSendworkOrderDto;
import com.toman.JavaBean.SendworkorderEntity;
import com.toman.R;
import com.toman.Util.ViewUtil;
import com.toman.toolbar.ToolBarActivity;
import com.toman.widget.CustomProgressBar;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class GetInfActivity extends ToolBarActivity {
    @BindView(R.id.iv_more)
    ImageView ivMore;
    @BindView(R.id.rl_more)
    RelativeLayout rlMore;
    @BindView(R.id.tv_progress)
    TextView tvProgress;
    @BindView(R.id.pb_base)
    CustomProgressBar pbBase;
    @BindView(R.id.tv_completed_count)
    TextView tvCompletedCount;
    @BindView(R.id.tv_demand_count)
    TextView tvDemandCount;
    @BindView(R.id.tv_qualified_count)
    TextView tvQualifiedCount;
    @BindView(R.id.tv_waste_count)
    TextView tvWasteCount;
    @BindView(R.id.tv_scrapped_count)
    TextView tvScrappedCount;
    @BindView(R.id.tv_remake_count)
    TextView tvRemakeCount;
    @BindView(R.id.tv_reuse_count)
    TextView tvReuseCount;
    @BindView(R.id.rl_progress)
    RelativeLayout rlProgress;
    @BindView(R.id.tv_order_name)
    TextView tvOrderName;
    @BindView(R.id.tv_beltline_child)
    TextView tvBeltlineChild;
    @BindView(R.id.tv_sendwork_count_child)
    TextView tvSendworkCountChild;
    @BindView(R.id.ll_more)
    LinearLayout llMore;
    @BindView(R.id.iv_more2)
    ImageView ivMore2;
    @BindView(R.id.rl_more2)
    RelativeLayout rlMore2;
    @BindView(R.id.tv_progress2)
    TextView tvProgress2;
    @BindView(R.id.pb_base2)
    CustomProgressBar pbBase2;
    @BindView(R.id.tv_completed_count2)
    TextView tvCompletedCount2;
    @BindView(R.id.tv_demand_count2)
    TextView tvDemandCount2;
    @BindView(R.id.tv_qualified_count2)
    TextView tvQualifiedCount2;
    @BindView(R.id.tv_waste_count2)
    TextView tvWasteCount2;
    @BindView(R.id.tv_scrapped_count2)
    TextView tvScrappedCount2;
    @BindView(R.id.tv_remake_count2)
    TextView tvRemakeCount2;
    @BindView(R.id.tv_reuse_count2)
    TextView tvReuseCount2;
    @BindView(R.id.rl_progress2)
    RelativeLayout rlProgress2;
    @BindView(R.id.tv_sendwork_code)
    TextView tvSendworkCode;
    @BindView(R.id.rl_order_code)
    RelativeLayout rlOrderCode;
    @BindView(R.id.tv_sendwork_date)
    TextView tvSendworkDate;
    @BindView(R.id.rl_order_num)
    RelativeLayout rlOrderNum;
    @BindView(R.id.tv_completework_date)
    TextView tvCompleteworkDate;
    @BindView(R.id.tv_plan_id)
    TextView tvPlanId;
    @BindView(R.id.tv_customer)
    TextView tvCustomer;
    @BindView(R.id.tv_artline)
    TextView tvArtline;
    @BindView(R.id.tv_product_name)
    TextView tvProductName;
    @BindView(R.id.tv_batch_number)
    TextView tvBatchNumber;
    @BindView(R.id.tv_stove_number)
    TextView tvStoveNumber;
    @BindView(R.id.tv_sendwork_count)
    TextView tvSendworkCount;
    @BindView(R.id.ll_more2)
    LinearLayout llMore2;
    @BindView(R.id.ll_order)
    LinearLayout llOrder;
    @BindView(R.id.tv_check_man)
    TextView tvCheckMan;
    @BindView(R.id.rl_check)
    RelativeLayout rlCheck;
    @BindView(R.id.tv_check_time)
    TextView tvCheckTime;
    @BindView(R.id.rl_check_time)
    RelativeLayout rlCheckTime;
    @BindView(R.id.tv_edit_man)
    TextView tvEditMan;
    @BindView(R.id.tv_edit_time)
    TextView tvEditTime;
    @BindView(R.id.ll_check)
    LinearLayout llCheck;
    private ReceiveSendworkOrderDto bean;
    private String status;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_get_inf);
        ButterKnife.bind(this);
        initToolBar(BaseEnum.GET.detail());
        initIntent();
        initView();
    }

    private void initView() {
tvOrderName.setText(bean.getOperationorderEntity().getOrderName());
tvBeltlineChild.setText(bean.getBeltlineEntity().getBeltlineName());
tvSendworkCountChild.setText(bean.getSendworkOrderMappingEntity().getWorkCount()+"");
        ViewUtil.invisible(tvProgress,tvProgress2);
        SendworkorderEntity bean2=bean.getSendworkorderEntity();
//        总派工单
        tvQualifiedCount2.setText("合格数量:" + bean2.getSendworkStaticsCount().getQualifiedCount() + "");
        tvScrappedCount2.setText("报废数量:" + bean2.getSendworkStaticsCount().getScrappedCount() + "");
        tvCompletedCount2.setText(bean2.getSendworkStaticsCount().getCompletedCount() + "");
        tvWasteCount2.setText("料废数量:" + bean2.getSendworkStaticsCount().getWasteCount() + "");
        tvRemakeCount2.setText("返工数量:" + bean2.getSendworkStaticsCount().getRemakeCount() + "");
        tvReuseCount2.setText("回用数量:" + bean2.getSendworkStaticsCount().getReuseCount() + "");
        tvDemandCount2.setText(bean2.getSendworkCount() + "");
        pbBase2.setMaxProgress((Integer.parseInt(bean2.getSendworkCount() + "")));
        if (bean2.getSendworkCount() >= bean2.getSendworkStaticsCount().getCompletedCount()) {
            pbBase2.setCurProgress(Integer.parseInt(bean2.getSendworkStaticsCount().getCompletedCount() + ""), 2000);
        } else {
            pbBase2.setCurProgress(Integer.parseInt(bean2.getSendworkCount() + ""), 2000);
        }
        tvSendworkDate.setText(bean2.getSendworkDate());
        tvCompleteworkDate.setText(bean2.getCompleteworkDate());
        tvSendworkCode.setText(bean2.getSendworkCode());
        tvPlanId.setText(bean.getPlanEntity().getPlanNum()+"");
        tvCustomer.setText(bean.getPlanEntity().getCustomer());
//       tvCustomer.setText();
        tvArtline.setText(bean.getOperationArtlineEntity().getArtlineName());
        tvProductName.setText(bean.getProductEntity().getProductName());
        tvBatchNumber.setText(bean2.getBatchNumber());
        tvStoveNumber.setText(bean2.getStoveNumber());
        tvSendworkCount.setText(bean2.getSendworkCount()+"");
        if (status.equals("0")){
            ViewUtil.gone(rlProgress,rlCheck);
        }
        else {
            ArleadyReceiveSendworkOrderCount bean1=bean.getArleadyReceiveSendworkOrderCount();
            tvQualifiedCount.setText("合格数量:" + bean1.getQualifiedCount() + "");
            tvScrappedCount.setText("报废数量:" + bean1.getScrappedCount() + "");
            tvCompletedCount.setText(bean1.getCompletedCount() + "");
            tvWasteCount.setText("料废数量:" + bean1.getWasteCount() + "");
            tvRemakeCount.setText("返工数量:" + bean1.getRemakeCount() + "");
            tvReuseCount.setText("回用数量:" + bean1.getReuseCount() + "");
            tvDemandCount.setText(bean.getSendworkOrderMappingEntity().getWorkCount()+ "");
            pbBase.setMaxProgress((Integer.parseInt(bean.getSendworkOrderMappingEntity().getWorkCount()+ "")));
            if (bean.getSendworkOrderMappingEntity().getWorkCount()>= bean1.getCompletedCount()) {
                pbBase.setCurProgress(Integer.parseInt(bean1.getCompletedCount() + ""), 2000);
            } else {
                pbBase.setCurProgress(Integer.parseInt(bean1.getCompletedCount() + ""), 2000);
            }
        }


    }

    private void initIntent() {
        status = getIntent().getStringExtra("status");
        bean = (ReceiveSendworkOrderDto) getIntent().getSerializableExtra("bean");
    }
    @OnClick({R.id.rl_more, R.id.rl_more2})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rl_more:
                ViewUtil.hide(llMore, ivMore);

                break;
            case R.id.rl_more2:
                ViewUtil.hide(llMore2, ivMore2);

                break;
        }
    }
}
